<?php echo $this->render('/public/header'); ?>
<div id="main" class="col-lg-12 col-md-12 col-xs-12 col-sm-12">
    <div class="col-lg-1 col-xs-1 col-sm-1">
        <select class="form-control" onchange="Page.change_year(this)">
            <option value=0>--选择年份--</option>
            <option <?php if (yii::$app->request->get('year') == 2019) {
                echo 'selected';
            } ?>>2019
            </option>
            <option <?php if (yii::$app->request->get('year') == 2018) {
                echo 'selected';
            } ?>>2018
            </option>
            <option <?php if (yii::$app->request->get('year') == 2017) {
                echo 'selected';
            } ?>>2017
            </option>
            <option <?php if (yii::$app->request->get('year') == 2016) {
                echo 'selected';
            } ?>>2016
            </option>
        </select>
    </div>
    <div class="col-lg-12 col-md-12 col-xs-12 col-sm-12">
        <b style="margin-left:40%;font-size:40px">年度支出统计汇总表</b>
        <table class="table table-borded">
            <thead>
            <tr>
                <th style="color:white;background-color:rgb(47,117,181)">月份</th>
                <?php foreach ($this->params['bank_type'] as $v) :
                    ; ?>
                    <th style="color:white;background-color:rgb(47,117,181)"><?php echo $v['name']; ?></th>
                <?php endforeach; ?>
                <th style="color:white;background-color:rgb(47,117,181)">总计</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($this->params['list'] as $k => $v) : ?>
                <tr>
                    <td><?php echo $k; ?></td>
                    <?php foreach ($this->params['bank_type'] as $v2):; ?>
                        <td><?php $pay = isset($v['data'][$v2['id']]) ? ($v['data'][$v2['id']]['out_money'] - $v['data'][$v2['id']]['in_money']) : ""; ?>
                            <a href="/table/bank?begin_time=<?php echo $k;?>-01&end_time=<?php echo $k;?>-31&type=<?php echo $v2['id'];?>"><?php echo $pay; ?></a>
                        </td>
                    <?php endforeach; ?>
                    <td><?php echo $v['data']['total']; ?></td>
                </tr>
            <?php endforeach; ?>
            <?php if($this->params['list']):?>
            <tr>
                <td>total</td>
                <?php foreach ($this->params['bank_type'] as $v):; ?>
                    <td><a href='/table/bank?begin_time={$year}-01-01&end_time={$year}-12-31&type={$v2['
                           id']}'><?php echo isset($this->params['total'][$v['id']]) ? ($this->params['total'][$v['id']]['out_money'] - $this->params['total'][$v['id']]['in_money']) : ''; ?></a>
                    </td>
                <?php endforeach; ?>
                <td><?php echo $this->params['total']['total']; ?></td>
            </tr>
        <?php endif;?>
            </tbody>
        </table>
    </div>
</div>
<script>
    var Page = {};
    Page.change_year = function (e) {
        window.location.href = "/table/month_pay?year=" + e.value;
    }
</script>
<?php echo $this->render('/public/footer'); ?>
